import request from "@/util/http";
import qs from "qs";

export default {
  //渲染页面接口
  gain() {
    return request({
      method: "get",
      params: {
        _gp: "admin.freight",
        _mt: "getAllFreightTemplate"
      }
    });
  },
  //新增管理员
  adduser(form) {
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin.freight",
        _mt: "addFreightTemplate",
        templateName: form.templateName,
        deliveryDeadline: form.deliveryDeadline,
        defaultFreePrice: form.defaultFreePrice,
        defaultFirstNum: form.defaultFirstNum,
        defaultFirstPrice: form.defaultFirstMoney,
        defaultContinueNum: form.defaultContinueNum,
        defaultContinuePrice: form.defaultContinueMoney,
        spuLocation: form.spuLocation,
        freightTemplateCarriageDOList: JSON.stringify(
          form.freightTemplateCarriageDOList
        )
      })
    });
  },
  //删除接口
  cancel(form) {
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin.freight",
        _mt: "deleteFreightTemplate",
        templateId: form.templateId //模板编号id
      })
    });
  },
  //编辑角色
  compile(form) {
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin.freight",
        _mt: "updateFreightTemplate",
        templateName: form.templateName,
        deliveryDeadline: form.deliveryDeadline,
        defaultFreePrice: form.defaultFreePrice,
        defaultFirstNum: form.defaultFirstNum,
        defaultFirstPrice: form.defaultFirstMoney,
        defaultContinueNum: form.defaultContinueNum,
        defaultContinuePrice: form.defaultContinueMoney,
        spuLocation: form.spuLocation,
        freightTemplateCarriageDOList: JSON.stringify(
          form.freightTemplateCarriageDOList
        ),
        templateId: form.templateId
      })
    });
  }
};
